package Demo1;

import java.util.Arrays;
import java.util.Collections;
import java.util.List;

public class Test {
    //    public static void main(String[] args) {
////        int[] array = {1000000000,1000000000,11};
////        boolean b = containsDuplicate(array);
////        System.out.println(b);
////
////
////    }
////    public static boolean containsDuplicate(int[] nums) {
////        int min = nums[0];
////        int max = nums[0];
////        for(int i = 0;i<nums.length;i++){
////            if(nums[i]<min){
////                min = nums[i];
////            }
////            if(nums[i]>max){
////                max = nums[i];
////            }
////        }
////        int[] array = new int[max - min +1];
////        for(int k = 0;k<nums.length;k++){
////            array[nums[k]-min]++;
////        }
////        for(int j = 0;j<array.length;j++){
////            if(array[j]>=2){
////                return true;
////            }
////        }
////        return false;
//
//
//
//    }
    public static void main(String[] args) {
        String str = "hello world";
        str.indexOf
    }
    public static List<String> summaryRanges(int[] nums) {
        if(nums.length == 0){
            return Collections.singletonList("[]");
        }
        String[] newArray = new String[nums.length];
        int index = 0;
        int left = 0;
        int right = 1;
        while(right<nums.length){
            if(nums[right] == nums[right-1]+1){
                right++;
            }else{
                if(right - left == 1){
                    newArray[index++] = String.valueOf(nums[left]);
                    left++;
                    right++;
                } else {
                    newArray[index++] = nums[left]+"->"+(nums[right - 1]);
                    left = right;
                    right++;
                }
            }
        }
        if(left == nums.length - 1){
            newArray[index++] = String.valueOf(nums[left]);
        } else {
            newArray[index++] = nums[left]+"->"+(nums[right - 1]);
        }
        String[] array = Arrays.copyOf(newArray,index);
        return List.of(array);


    }
}
